London | 26-March-SDC | Ammad Ur Rehman | Sprint 4 | Implement shell tools (cat, ls, wc) in Python#540
Conversation
SlideGauge
left a comment
There was a problem hiding this comment.
Good job, left several comments, could you fix them please?
| continue | ||
|
|
||
| with open(path, "r") as file: | ||
| line_number = 1 |
There was a problem hiding this comment.
README requires cat -n sample-files/*.txt to behave like real cat -n, which numbers lines continuously across all files
There was a problem hiding this comment.
Real cat produces:
cat -n sample-files/*.txt
1 Once upon a time...
1 There was a house made of gingerbread.
1 It looked delicious.
2 I was tempted to take a bite of it.
3 But this seemed like a bad idea...
4
5 There's more to come, though...Python cat produces:
python3 cat.py -n sample-files/*.txt
1 Once upon a time...
1 There was a house made of gingerbread.
1 It looked delicious.
2 I was tempted to take a bite of it.
3 But this seemed like a bad idea...
4
5 There's more to come, though...The only difference is the indentation.
|
|
||
| args = parser.parse_args() | ||
|
|
||
| entries = os.listdir(args.filepath) |
There was a problem hiding this comment.
Does os.listdir return dir list in an alphabetical order? Compare with what real ls does
There was a problem hiding this comment.
When I run ls -a, it produces:
. ls.py README.md
.. node_modules sample-filesWhen I run the Python variant, python3 ls.py -a:
. .. README.md ls.py node_modules sample-filesThe alphabetically ordering does not match.
|
Thanks for the review. I've made some changes. |
|
|
||
| try: | ||
| with open(path, "r") as file: | ||
| line_number = 1 |
There was a problem hiding this comment.
numbering still restarts per file, not continuous.
Learners, PR Template
Self checklist
Changelist
Reimplement the shell programs as a Python program.